<template>
	<view class="frozen-list">
		<view class="list-container">
			<view class="frozen-item" v-for="item in frozenList" :key="item.id">
				<view class="item-header">
					<text class="type">{{getFrozenType(item.type)}}</text>
					<text class="status" :class="item.status === 1 ? 'frozen' : 'unfrozen'">
						{{item.status === 1 ? '冻结中' : '已解冻'}}
					</text>
				</view>
				<view class="item-content">
					<view class="amount">
						<text class="label">冻结金额：</text>
						<text class="value">¥{{item.amount}}</text>
					</view>
					<view class="time">{{item.createTime}}</view>
				</view>
				<view class="item-footer" v-if="item.remark">
					<text class="remark">备注：{{item.remark}}</text>
				</view>
			</view>

			<!-- 空状态 -->
			<view class="empty-state" v-if="frozenList.length === 0">
				<image src="/static/images/empty-data.png" mode="aspectFit"></image>
				<text>暂无冻结记录</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		listMyWallet
	} from '@/api/wallet/walletFrozen.js'

	export default {
		data() {
			return {
				frozenList: []
			}
		},
		onLoad() {
			this.getFrozenList()
		},
		methods: {
			getFrozenList() {
				listMyWallet().then(res => {
					this.frozenList = res.rows || []
				}).catch(err => {
					uni.showToast({
						title: err.message || '获取数据失败',
						icon: 'none'
					})
				})
			},
			getFrozenType(type) {
				const typeMap = {
					1: '订单预付',
					2: '提现',
					3: '其他'
				}
				return typeMap[type] || '未知类型'
			}
		}
	}
</script>

<style lang="scss" scoped>
	.frozen-list {
		min-height: 100vh;
		background: #f5f5f5;
		padding: 20rpx;

		.frozen-item {
			background: #fff;
			border-radius: 12rpx;
			padding: 30rpx;
			margin-bottom: 20rpx;

			.item-header {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-bottom: 20rpx;

				.type {
					font-size: 32rpx;
					color: #333;
					font-weight: bold;
				}

				.status {
					font-size: 26rpx;

					&.frozen {
						color: #ff6b35;
					}

					&.unfrozen {
						color: #999;
					}
				}
			}

			.item-content {
				.amount {
					margin-bottom: 12rpx;

					.label {
						font-size: 28rpx;
						color: #666;
					}

					.value {
						font-size: 32rpx;
						color: #333;
						font-weight: bold;
					}
				}

				.time {
					font-size: 24rpx;
					color: #999;
				}
			}

			.item-footer {
				margin-top: 16rpx;
				padding-top: 16rpx;
				border-top: 1rpx solid #eee;

				.remark {
					font-size: 26rpx;
					color: #666;
				}
			}
		}

		.empty-state {
			display: flex;
			flex-direction: column;
			align-items: center;
			padding: 100rpx 0;

			image {
				width: 200rpx;
				height: 200rpx;
				margin-bottom: 20rpx;
			}

			text {
				font-size: 28rpx;
				color: #999;
			}
		}
	}
</style>